package com.ssm.controller;

import com.ssm.pojo.Lise;
import com.ssm.pojo.PageInfo;
import com.ssm.service.LiseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class LiseController {

    @Autowired
    private LiseService liseService;

    @RequestMapping("lise.html")
    public String lise(){
        return "leading/index";
    }

    @RequestMapping("getLise.html")
    public String getLise(Lise lise, @RequestParam(defaultValue = "1") Integer pn, Model model) {
        if (pn < 1) {
            pn = 1;
        }
        PageInfo<Lise> users = liseService.getLiseList(lise, pn, 9);
        model.addAttribute("pageInfo", users);
        return "leading/index";
    }

//    @RequestMapping("getLise.html")
//    public String getLise(Model model){
//        List<Lise> liseList = liseService.getLise();
//        model.addAttribute("lise", liseList);
//        return  "leading/index";
//    }

    @RequestMapping("/list.html")
    public String list(Lise lise, @RequestParam(defaultValue = "1") Integer pn, Model model) {
        if (pn < 1) {
            pn = 1;
        }
        PageInfo<Lise> users = liseService.getLiseList(lise, pn, 9);
        model.addAttribute("pageInfo", users);
        return "leading/information";
    }

    @RequestMapping("getListById.html")
    public String getListById(Model model,Integer id){
        Lise lise = liseService.getLiseById(id);
        model.addAttribute("lise",lise);
        return "leading/commodityDetails";
    }

}
